

K = 2
N = 6

k_lst = [0, 1, 6, 5] 
k_env = {}
k_set = set([])
def dfs(k): 
	if k==N: 
		ss = sum(k_env.values())
		#print "%-20s %d" % (k_env.values(), ss)
		k_set.add(ss)
		return 
	for i in k_lst: 
		k_env[k] = i
		dfs(k+1)
		del k_env[k]

def loop(ki):
	global k_env, k_set, k_lst
	k_lst[-1] = ki
	k_env = {}
	k_set = set([])
	dfs(0)
	a = list(k_set)
	a.sort()
	x = a[0]
	n = len(a)
	print "N=%d, ki=%d, k_lst=%s:" % (N, ki, k_lst),
	for i in range(1, n): 
		y = a[i]
		if y-x>1: 
			print "[%d]" % y,
		else:
			print "%d" % y,
		x = y
	print

for i in range(k_lst[-2]+1, N*k_lst[-2]+2): 
	loop(i)
